import axios from 'axios'
// var qs = require('qs')
const host = 'http://tft-dev/api5'

//------------------------------会员模块-----------------------
// 列表会员
export function getConsumerList (data) {
  const url = `${host}/consumer/list`
  return axios.post(url, data).then(res => {
    return Promise.resolve(res.data)
  })
}

// 会员信息查看
export function consumerDetail (id) {
  const url = `${host}/consumer/query/${id}`
  return axios.post(url).then(res => {
    return Promise.resolve(res.data)
  })
}

// 编辑会员状态
export function editConsumerStatus (data) {
  const url = `${host}/consumer/modifyStatus`
  return axios.post(url, data).then(res => {
    return Promise.resolve(res.data)
  })
}

//------------------------------会员积分模块-----------------------
// 根据用户di查询积分交付记录
export function getCustomerIntegral(customerId) {
  const url = `${host}/customerIntegralRecord/${customerId}/findIntegralByCustomerId`
  return axios.post(url).then(res => {
    return Promise.resolve(res.data)
  })
}

// 添加积分交付信息
export function addIntegral(customerId, data) {
  const url = `${host}/customerIntegralRecord/${customerId}/updateIntegral`
  return axios.post(url).then(res => {
    return Promise.resolve(res.data)
  })
}

//------------------------------成长模块-----------------------
// 列表会员成长规则
export function selectConsumerGrow(data) {
  const url = `${host}/consumerGrowRule/list`
  return axios.post(url, data).then(res => {
    return Promise.resolve(res.data)
  })
}

// 增加会员成长规则
export function addConsumerGrow(data) {
  const url = `${host}/consumerGrowRule/create`
  return axios.post(url, data).then(res => {
    return Promise.resolve(res.data)
  })
}

// 编辑会员成长规则
export function editConsumerGrow(data) {
  const url = `${host}/consumerGrowRule/modify`
  return axios.post(url, data).then(res => {
    return Promise.resolve(res.data)
  })
}
